/*
* LWJGLRenderer.java
* Copyright (C) 2004
*
* $Id: LWJGLRenderer.java,v 1.3 2004/12/20 21:49:14 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
using System;
using Defines = Suake2.UI.Defines;
using Suake2.UI.client;
using Misc = Suake2.UI.render.lwjgl.Misc;
using KBD = Suake2.UI.sys.KBD;
using LWJGLKBD = Suake2.UI.sys.LWJGLKBD;
namespace Suake2.UI.render
{
	
	/// <summary> LWJGLRenderer
	/// 
	/// </summary>
	/// <author>  dsanders/cwei
	/// </author>
	sealed class LWJGLRenderer:Misc, refexport_t, Ref
	{
		public System.String Name
		{
			// ============================================================================
			// Ref interface
			// ============================================================================
			
			
			get
			{
				return DRIVER_NAME;
			}
			
		}
		public KBD KeyboardHandler
		{
			get
			{
				return kbd;
			}
			
		}
		
		private LWJGLKBD kbd = new LWJGLKBD();
		
		public const System.String DRIVER_NAME = "lwjgl";
		
		
		private LWJGLRenderer()
		{
		}
		
		// ============================================================================
		// public interface for Renderer implementations
		//
		// refexport_t (ref.h)
		// ============================================================================
		
		/// <seealso cref="jake2.client.refexport_t.Init()">
		/// </seealso>
		public bool Init(int vid_xpos, int vid_ypos)
		{
			
			// pre init
			if (!R_Init(vid_xpos, vid_ypos))
				return false;
			// post init		
			bool ok = R_Init2();
			if (!ok)
			{
				VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for LWJGL renderer\n");
			}
			return ok;
		}
		
		/// <seealso cref="jake2.client.refexport_t.Shutdown()">
		/// </seealso>
		public void  Shutdown()
		{
			R_Shutdown();
		}
		
		/// <seealso cref="jake2.client.refexport_t.BeginRegistration(java.lang.String)">
		/// </seealso>
		public void  BeginRegistration(System.String map)
		{
			R_BeginRegistration(map);
		}
		
		/// <seealso cref="jake2.client.refexport_t.RegisterModel(java.lang.String)">
		/// </seealso>
		public model_t RegisterModel(System.String name)
		{
			return R_RegisterModel(name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.RegisterSkin(java.lang.String)">
		/// </seealso>
		public image_t RegisterSkin(System.String name)
		{
			return R_RegisterSkin(name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.RegisterPic(java.lang.String)">
		/// </seealso>
		public image_t RegisterPic(System.String name)
		{
			return Draw_FindPic(name);
		}
		/// <seealso cref="jake2.client.refexport_t.SetSky(java.lang.String, float, float[])">
		/// </seealso>
		public void  SetSky(System.String name, float rotate, float[] axis)
		{
			R_SetSky(name, rotate, axis);
		}
		
		/// <seealso cref="jake2.client.refexport_t.EndRegistration()">
		/// </seealso>
		public void  EndRegistration()
		{
			R_EndRegistration();
		}
		
		/// <seealso cref="jake2.client.refexport_t.RenderFrame(jake2.client.refdef_t)">
		/// </seealso>
		public void  RenderFrame(refdef_t fd)
		{
			R_RenderFrame(fd);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawGetPicSize(java.awt.Dimension, java.lang.String)">
		/// </seealso>
		//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
		public void  DrawGetPicSize(ref System.Drawing.Size dim, System.String name)
		{
			//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
			Draw_GetPicSize(ref dim, name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawPic(int, int, java.lang.String)">
		/// </seealso>
		public void  DrawPic(int x, int y, System.String name)
		{
			Draw_Pic(x, y, name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawStretchPic(int, int, int, int, java.lang.String)">
		/// </seealso>
		public void  DrawStretchPic(int x, int y, int w, int h, System.String name)
		{
			Draw_StretchPic(x, y, w, h, name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawChar(int, int, int)">
		/// </seealso>
		public void  DrawChar(int x, int y, int num)
		{
			Draw_Char(x, y, num);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawTileClear(int, int, int, int, java.lang.String)">
		/// </seealso>
		public void  DrawTileClear(int x, int y, int w, int h, System.String name)
		{
			Draw_TileClear(x, y, w, h, name);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawFill(int, int, int, int, int)">
		/// </seealso>
		public void  DrawFill(int x, int y, int w, int h, int c)
		{
			Draw_Fill(x, y, w, h, c);
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawFadeScreen()">
		/// </seealso>
		public void  DrawFadeScreen()
		{
			Draw_FadeScreen();
		}
		
		/// <seealso cref="jake2.client.refexport_t.DrawStretchRaw(int, int, int, int, int, int, byte[])">
		/// </seealso>
		public void  DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, sbyte[] data)
		{
			Draw_StretchRaw(x, y, w, h, cols, rows, data);
		}
		
		/// <seealso cref="jake2.client.refexport_t.CinematicSetPalette(byte[])">
		/// </seealso>
		public void  CinematicSetPalette(sbyte[] palette)
		{
			R_SetPalette(palette);
		}
		
		/// <seealso cref="jake2.client.refexport_t.BeginFrame(float)">
		/// </seealso>
		public void  BeginFrame(float camera_separation)
		{
			R_BeginFrame(camera_separation);
		}
		
		/// <seealso cref="jake2.client.refexport_t.EndFrame()">
		/// </seealso>
		public void  EndFrame()
		{
			GLimp_EndFrame();
		}
		
		/// <seealso cref="jake2.client.refexport_t.AppActivate(boolean)">
		/// </seealso>
		public void  AppActivate(bool activate)
		{
			GLimp_AppActivate(activate);
		}
		
		public int apiVersion()
		{
			return Defines.API_VERSION;
		}
		
		public override System.String ToString()
		{
			return DRIVER_NAME;
		}
		
		public refexport_t GetRefAPI()
		{
			return this;
		}
		static LWJGLRenderer()
		{
			{
				Renderer.register(new LWJGLRenderer());
			}
		}
	}
}